home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Environments
/
Open Prolog 1.0.3d33
/
External Predicates…
/
Sources
/
OpenPrologMultipleChoice.p
< prev
next >
Wrap
Text File
|
1995-11-10
|
6KB
|
162 lines
{$D+} { MacsBug symbols on }
{$R+} { No range checking }
UNIT OpenPrologDialogs;
INTERFACE
USES quickdraw, standardFile, TextUtils,
prlxdefinitions, prlxLibraries, traps, gestaltEqu;
PROCEDURE entrypoint(plist: prlxptr);
IMPLEMENTATION
CONST
kMCBase = 154;
kMCDLOG = kMCBase;
kMCDITL = kMCBase;
PROCEDURE main(plist: prlxptr);
FORWARD;
PROCEDURE entrypoint(plist: prlxptr);
BEGIN
main(plist);
END;
PROCEDURE main;
VAR
theOldPort: grafPtr;
theHandle: handle;
i, j: integer;
theRect: rect;
PROCEDURE checkOSErr(hostErrorCode: osErr;
errorKind, argumentIndex: longint;
s: Str255);
BEGIN
IF hostErrorCode <> noErr THEN
BEGIN
signalError(errorKind, argumentIndex, hostErrorCode, s, plist);
exit(main);
END;
END;
BEGIN
WITH plist^ DO
BEGIN
outcome := noErrorSucceed;
determinate := true;
CASE request OF
getPRLXInfo:
BEGIN
data[1] := 1; {number of predicates defined}
data[2] := eventsVersion;
data[3] := 0
END;
initialisepredicate:
CASE id OF
1:
BEGIN
s := 'system$multiple$choice'; {name}
data[1] := 15;
{Name,Prompt,OKtext,CancelText,ReplyText,Text1,Reply1,Text2,Reply2,Text3,Reply3
Text4,Reply4,Text5,Reply5}
END;
OTHERWISE
signalError(implementationError, - 1, 0,
'predicate index out of range at initialise',
plist);
END;
callpredicate:
CASE id OF
1:
WITH plist^ DO
BEGIN
dialogPtr(data[2]) := getNewDialog(kMCDLOG, NIL,
windowPtr( - 1));
IF dialogPtr(data[2]) <> NIL THEN
BEGIN
getPort(theOldPort);
setPort(dialogPtr(data[2]));
{window name}
setWTitle(dialogPtr(data[2]), text(1, plist));
{prompt}
getDItem(dialogPtr(data[2]), 3, j, theHandle, theRect);
setIText(theHandle, textOfAtomicList(2, plist));
{default button}
getDItem(dialogPtr(data[2]), 1, j, theHandle, theRect);
IF text(3, plist) = '' THEN
setCTitle(controlHandle(theHandle), 'OK')
ELSE
setCTitle(controlHandle(theHandle), text(3, plist));
{cancel button}
getDItem(dialogPtr(data[2]), 2, j, theHandle, theRect);
IF text(4, plist) = '' THEN
hideControl(controlHandle(theHandle))
ELSE
BEGIN
setCTitle(controlHandle(theHandle), text(4, plist));
showControl(controlHandle(theHandle));
END;
{multiple choices}
FOR i := 5 TO 9 DO
BEGIN
IF text(i * 2 - 4, plist) = '[]' THEN
BEGIN
hideDItem(dialogPtr(data[2]),i);
hideDItem(dialogPtr(data[2]),i+5);
END
ELSE
begin
getDItem(dialogPtr(data[2]), i, j, theHandle, theRect);
setIText(theHandle, textOfAtomicList(i * 2 - 4,
plist));
end;
END;
showWindow(dialogPtr(data[2]));
openPrologDialogFilter(i,plist);
{return text of button pressed}
getDItem(dialogPtr(data[2]), i, j, theHandle, theRect);
getCTitle(controlHandle(theHandle), s);
successful := returnAtom(5, s, plist);
FOR i := 10 TO 14 DO
BEGIN
getDItem(dialogPtr(data[2]), i, j, theHandle, theRect);
getIText(theHandle, s);
successful := successful AND returnString(i * 2 - 13, s,
plist);
END;
setPort(theOldPort);
disposeDialog(dialogPtr(data[2]));
END; {if dialogPtr<>nil}
END; {with}
OTHERWISE
signalError(implementationError, - 1, 0,
'predicate index out of range at callPredicate',
plist);
END; {case}
closepredicate:
BEGIN
CASE id OF
1: ;
2: ;
OTHERWISE
signalError(implementationError, - 1, 0,
'predicate index out of range at closePredicate',
plist);
END;
END;
OTHERWISE
signalError(implementationError, - 1, 0,
'unknown call to OpenPrologDialogs external predicate suite'
, plist);
END;
END;
END;
END.